/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import com.assg2.dao.DaoMovie;
import com.assg2.dao.DaoShow;
import com.movie.Movie;
import com.movie.Show;
import java.util.Date;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author alexnewski
 */
public class testshow {

    public testshow() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }
    // TODO add test methods here.
    // The methods must be annotated with annotation @Test. For example:
    //

    @Test
    public void hello() throws ParseException {
        DaoMovie daomovie = new DaoMovie();
        DaoShow daoshow = new DaoShow();

        Movie m = (Movie) daomovie.findById(2);
        Show s = (Show) daoshow.findById(1);
        Date exp = TransformToDate("05-05-2011");
        Date comb = CombineDateAndTime(exp, s.getStarts());
        System.out.println(comb);
        int i = daoshow.SeatsAvailable(s, comb);
        System.out.println(i);
        assertNotNull(comb);

    }

    protected Date CombineDateAndTime(Date date, Date time) {
        return new Date(
                date.getYear(), date.getMonth(), date.getDay() + 1,
                time.getHours(), time.getMinutes(), time.getSeconds());

    }

    protected Date TransformToDate(String str_date) {
        try {
            DateFormat dfm = new SimpleDateFormat("dd-MM-yyyy");
            return dfm.parse(str_date);
        } catch (ParseException e) {
            System.out.println("Exception :" + e);
        }
        return null;
    }
}
